import request from '@/config/axios'

export interface PageParam {
  pageNo: number
  pageSize: number
}

export interface EvalProfessionVO {
  id?: number
  professionCode: string
  professionName: string
  professionCategory?: string
  applicableLevels?: string[] | string
  approvalStatus: number
  filingDate?: string
  approvalDate?: string
  approvalComments?: string
  documents?: string
  createTime?: Date
}

export interface EvalProfessionPageReqVO extends PageParam {
  professionCode?: string
  professionName?: string
  professionCategory?: string
  approvalStatus?: number
  createTime?: Date[]
}

// 查询职业工种分页
export const getProfessionPage = (params: EvalProfessionPageReqVO) => {
  return request.get({ url: '/eval/profession/page', params })
}

// 查询职业工种详情
export const getProfession = (id: number) => {
  return request.get({ url: '/eval/profession/get?id=' + id })
}

// 新增职业工种
export const createProfession = (data: EvalProfessionVO) => {
  return request.post({ url: '/eval/profession/create', data })
}

// 修改职业工种
export const updateProfession = (data: EvalProfessionVO) => {
  return request.put({ url: '/eval/profession/update', data })
}

// 删除职业工种
export const deleteProfession = (id: number) => {
  return request.delete({ url: '/eval/profession/delete?id=' + id })
}

// 导出职业工种
export const exportProfession = (params: EvalProfessionPageReqVO) => {
  return request.download({ url: '/eval/profession/export-excel', params })
}

// 根据父级ID获得职业工种列表
export const getProfessionListByParentId = (parentId: number) => {
  return request.get({ url: '/eval/profession/list-by-parent?parentId=' + parentId })
}

// 根据层级获得职业工种列表
export const getProfessionListByLevel = (professionLevel: number) => {
  return request.get({ url: '/eval/profession/list-by-level?professionLevel=' + professionLevel })
}

// 根据状态获得职业工种列表
export const getProfessionListByStatus = (professionStatus: number) => {
  return request.get({ url: '/eval/profession/list-by-status?professionStatus=' + professionStatus })
}

// 根据审核状态获得职业工种列表
export const getProfessionListByApprovalStatus = (approvalStatus: number) => {
  return request.get({ url: '/eval/profession/list-by-approval-status?approvalStatus=' + approvalStatus })
}

// 获得职业工种树形结构
export const getProfessionTree = () => {
  return request.get({ url: '/eval/profession/tree' })
}

// 获得职业工种精简信息列表
export const getSimpleProfessionList = (): Promise<EvalProfessionVO[]> => {
  return request.get({ url: '/eval/profession/simple-list' })
}
